package demo4;

import org.omg.CosNaming.NamingContextExtPackage.StringNameHelper;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ASUS
 * Date: 2023-11-15
 * Time: 17:58
 */
class Animal{
    public String name;
    public int age;
    public Animal(String name, int age){
        this.name = name;
        this.age = age;
        eat();
        System.out.println("带2个参数的构造方法");
    }
    public void eat(){
        System.out.println(this.name+"正在吃饭");
    }
}
class Dog extends Animal {
    public Dog(String name, int age){
        super(name,age);
    }

    public void bark(){
        System.out.println(this.name+"wa");
    }
    public void eat(){
        System.out.println(this.name+this.age+"吃狗粮");
    }
    public void wangwang(){
        System.out.println(this.name+ "wangwagnwang");
    }
}
public class Test1 {
    public static void main(String[] args) {
        Animal animal = new Dog("yyy",12);
        Dog dog = (Dog) animal;
        if (animal instanceof Dog){
            Dog dog1 = (Dog) animal;
            dog.wangwang();
        }
    }
    public static void main1(String[] args) {
        Dog dog = new Dog("diaozhatian",3);
        dog.bark();

        Animal animal = new Animal("hhh",1);
        animal.eat();
        Animal animal1 = new Dog("xxx",6);
        animal1.eat();
    }
}
